/*
 * data_format.c
 *
 * Funciones auxiliares para formateo de datos
 *
 */

#include <assert.h>
#include <time.h>
#include "data_format.h"

bstring format_time (time_t t) {
	bstring result = NULL;
	
	time_t dd = 0, hh = 0, mm = 0, ss = 0;
	assert (t >= 0);
	
	/* Separar en componentes */
	ss = t;
	mm = ss / 60; ss = ss % 60;
	hh = mm / 60; mm = mm % 60;
	dd = hh / 24; hh = hh % 24;
	
	result = bformat ("%.2ldD %.2ld:%.2ld:%.2ld", dd, hh, mm, ss);
	assert (result != NULL);
	
	return result;
}
